import request from '@/utils/request'
import { getServicePath } from '@/api/baseUrlConfig'
const servicePath = getServicePath()
// 根据顶部组织机构查询用户
export function getTreeByRole (data) {
  return request({
    url: servicePath.userServer + '/organization/getTreeByRole',
    method: 'post',
    data
  })
}

export function getList (data) {
  return request({
    url: servicePath.gzMetroMetroProjectServer + '/designScheme/getSchemeList',
    method: 'post',
    data
  })
}

// 获取设计方案统计
export function getStatistics (params) {
  return request({
    url: servicePath.gzMetroMetroProjectServer + '/designScheme/statistics',
    method: 'get',
    params
  })
}

// 获取详情
export function getDetail (params) {
  return request({
    url: servicePath.gzMetroMetroProjectServer + '/designScheme/getDetail',
    method: 'get',
    params
  })
}

// 获取审批进度列表
export function getApprovalList (data) {
  return request({
    url: servicePath.gzMetroMetroProjectServer + '/designScheme/getList',
    method: 'post',
    data
  })
}

// 获取方案历史记录
export function getSchemeHistory (params) {
  return request({
    url: servicePath.gzMetroMetroProjectServer + '/designScheme/getSchemeHistory',
    method: 'get',
    params
  })
}

// 保存草稿
export function saveDraft (data) {
  return request({
    url: servicePath.gzMetroMetroProjectServer + '/designScheme/saveDraft',
    method: 'post',
    headers: {
      showLoading: true
    },
    data
  })
}

// 发布
export function release (data) {
  return request({
    url: servicePath.gzMetroMetroProjectServer + '/designScheme/release',
    method: 'post',
    headers: {
      showLoading: true
    },
    data
  })
}

// 编辑审批情况
export function updApprovalInfo (data) {
  return request({
    url: servicePath.gzMetroMetroProjectServer + '/designScheme/updApprovalInfo',
    method: 'post',
    headers: {
      showLoading: true
    },
    data
  })
}

// 获取模型信息
export function getModuleById (params) {
  return request({
    url: servicePath.workFlowServer + '/module/getModuleById',
    method: 'get',
    params
  })
}

// 获取流程图片
export function picture (params) {
  return request({
    url: servicePath.workFlowServer + '/workflow/picture',
    method: 'get',
    responseType: 'blob',
    params
  })
}

// 获取流程审批信息
export function getProcessHistory (params) {
  return request({
    url: servicePath.workFlowServer + '/workflow/getProcessHistory',
    method: 'get',
    params
  })
}

export function download (id) {
  return request({
    url: `/bp-file-server/file/download/${id}`,
    headers: {
      showLoading: true
    },
    method: 'get',
    responseType: 'blob'
  })
}

// 查询敏感区域信息
export function getSensitiveArea (data) {
  return request({
    url: `${servicePath.gzMetroMetroProjectServer}/designScheme/getSensitiveArea`,
    method: 'post',
    data
  })
}
// 获取流程的审批文件

export function getProcessFile (params) {
  return request({
    url: `${servicePath.workFlowServer}/workflow/getProcessFile`,
    method: 'get',
    params
  })
}
